﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bluyel.Core
{
    /// <summary>
    /// Factory to build types.
    /// </summary>
    public class FactoryTypeBase
    {
        private IdFactory _idFactory;

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        public FactoryTypeBase(IdFactory idFactory)
        {
            _idFactory = idFactory;
        }

        //---------------------------------------------------------------------
        public ITypeBasic CreateTypeInt(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeIntId);

            ITypeBasic type = new TypeBasic(id, name);
            return type;
        }

        //---------------------------------------------------------------------
        public ITypeBasic CreateTypeLong(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeLongId);

            ITypeBasic type = new TypeBasic(id, name);
            return type;
        }
        //---------------------------------------------------------------------
        public ITypeBasic CreateTypeDouble(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeDoubleId);

            ITypeBasic type = new TypeBasic(id, name);
            return type;
        }
        //---------------------------------------------------------------------
        public ITypeBasic CreateTypeString(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeStringId);

            ITypeBasic type = new TypeBasic(id, name);
            return type;
        }
        //---------------------------------------------------------------------
        public ITypeBasic CreateTypeBool(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeBoolId);

            ITypeBasic type = new TypeBasic(id, name);
            return type;
        }

        //---------------------------------------------------------------------
        public ITypeVoid CreateTypeVoid(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeVoidId);

            ITypeVoid type = new TypeVoid(id, name);
            return type;
        }

        //---------------------------------------------------------------------
        public ITypeStruct CreateTypeStruct(string name)
        {
            UniqueId id = _idFactory.CreateId(TypeDef.TypeStructId);

            ITypeStruct type = new TypeStruct(id, name);
            return type;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Create a type enum.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        public TypeEnumString CreateTypeEnumString(string name, ITypeBasic type, TypeEnumSelectMode selectMode)
        {
            UniqueId id = _idFactory.CreateId();
            return CreateTypeEnumString(id, name, type, selectMode);
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Create a type enum.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        public TypeEnumString CreateTypeEnumString(UniqueId id, string name, ITypeBasic type, TypeEnumSelectMode selectMode)
        {
            if (string.IsNullOrWhiteSpace(name))
                return null;
            if (type == null)
                return null;

            return new TypeEnumString(id, name, type, selectMode);
        }
    }
}
